#ifndef __POLIGONIZE_H__
#define __POLIGONIZE_H__

typedef struct {
   float x,y,z;
} XYZ;

typedef struct {
   XYZ      p[3];
   XYZ      n[3];
} TRIANGLE;

typedef struct {
   XYZ      p[8];
   XYZ      g[8];
   float    val[8];
} GRIDCELL;

XYZ VertexInterp(int isolevel, XYZ p1, XYZ p2, float valp1, float valp2);

int Polygonize(GRIDCELL grid, int isolevel, TRIANGLE *triangles, int indEdges[8]);

void genTriangle(float PointBase[3], float dx, float dy, float dz,
                 float Val[8], float Grad[24], 
                 int iso, int *ntri, float tri[], int indEdges[8]);

void genTriangle(GRIDCELL gc, int iso, int *ntri, float tri[], int indEdges[8]);

#endif
